import QtQuick
import QtQuick.Window
import CustomCharts 1.0

Rectangle {
    color: "#F0F7FF"
    radius: 20
    clip: true

    Text {
        text: "折线图页面"
        font.pixelSize: 28
        color: "#2F3C4E"
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.topMargin: 20
        anchors.leftMargin: 20
    }

    LineChart {
        id: chart
        anchors.fill: parent
        offsetY: parent.height / 2
    }

    Component.onCompleted: {
        // === 创建三个数据序列 ===
        var points1 = []   // 正弦波
        var points2 = []   // 余弦波
        var points3 = []   // 正弦 + 余弦

        // === 配置参数 ===
        var numPoints = 33000     // 绘制点数
        var xStep = 0.01           // 每个采样点在 x 轴的间隔

        // === 生成数据点 ===
        for (var i = 0; i < numPoints; i++) {
            var x = i * xStep        // 当前点的 x 值

            points1.push(Qt.point(x, Math.sin(x) * 1))
            points2.push(Qt.point(x, Math.cos(x) * 1))
            points3.push(Qt.point(x, (Math.sin(x) + Math.cos(x)) * 0.5))
        }

        // === 将数据传给折线图 ===
        chart.setSeries([points1, points2, points3])
    }

}
